home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 745 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: solon.com!not-for-mail
  2. From: stanr@tiac.net (Stan Ryckman)
  3. Newsgroups: comp.std.c,comp.lang.c.moderated
  4. Subject: Re: printf() format extensions - looking for beta testers...
  5. Date: 14 Apr 1996 23:49:33 -0500
  6. Organization: Amber & Sneakers Fan Club
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4kskgt$roo@solutions.solon.com>
  10. References: <4kll9l$o5h@solutions.solon.com> <4kobun$8i2@solutions.solon.com> <4koecq$8up@solutions.solon.com> <4kr74a$k8o@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12.  
  13. In article <4kr74a$k8o@solutions.solon.com>,
  14. Sean 'Captain Napalm' Conner <spc@gate.net> wrote:
  15.  
  16. [snip most]
  17.  
  18. :  Well, why not change the approach?  The current printf() will accept a
  19. :line such as:
  20. :
  21. :        printf("%*s",someint,somestring);
  22. :
  23. :  To allow variable widths to be specified.  Why not extend that and pass in
  24. :the function pointers?  Something like:
  25. :
  26. :        printf("%p@",myfunctptr,myptrtype);
  27. :
  28. :  Where '@' specifies a format function, and the letter before it declares
  29. :the type using a single letter specification:
  30. :
  31. :        c    - char
  32. :        s    - short
  33. :        i    - int
  34. :        l    - long
  35. :        f    - float
  36. :        d    - double
  37. :
  38. :  With the following modifiers:
  39. :
  40. :        p    - pointer (if alone, void *)
  41. :        u    - unsigned
  42. :    
  43. :  Less chance of clashes, and more flexible I feel.
  44.  
  45. Uh, no.  "%p@" already has a meaning (for example) -- print a pointer
  46. representation, and then an '@' character.  Same for "%c@" etc.
  47.  
  48. You might retry this with "%@p@", "%@c@", ... . But I'd suggest
  49. changing your modifiers to be consistent with "normal" ones; e.g.
  50. "h" for short, "f" for double (note that float cannot be passed
  51. here), etc.
  52.  
  53. (Since "@" is not in the C character set, and doesn't even have
  54. a trigraph assigned to it, there are other problems with this...)
  55.  
  56. Cheers,
  57. Stan.
  58. --
  59. Stan Ryckman  (stanr@tiac.net)
  60.